package com.chengwei.ch.busdemo.activity;


import android.os.Bundle;
import android.util.Log;

import com.chengwei.ch.busdemo.R;
import com.chengwei.ch.busdemo.base.BaseActivity;
import com.chengwei.ch.busdemo.network.NetType;
import com.chengwei.ch.busdemo.network.NetworkLiveData;
import com.chengwei.ch.busdemo.view.MqttManager;


public class MainActivity extends BaseActivity implements MqttManager.OnMessageArrivedListener, NetworkLiveData.OnCheckNetWorkListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MqttManager.getInstance().getMQttDada("testtopic/zdk/test");
        MqttManager.getInstance().setOnMessageArrivedListener(this);
        NetworkLiveData.get(this).setOnCheckNetWorkListener(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    /**
     * 数据接收
     *
     * @param msg mqtt接收到的数据
     */
    @Override
    public void onMsgArrived(String msg) {
        Log.d("Tag", "数据接收 : subTopic ---> " + "msg --->" + msg);
    }

    /**
     * 检测网络
     *
     * @param netType 网络类型
     */
    @Override
    public void checkNetWork(NetType netType) {
        Log.d("Tag", "数据接收 : checkNetWork ---> " + "NetType --->" + netType);
    }
}
